import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nyh_motorcade_app/constant/constant.dart';

class PreviewPhotoController extends GetxController {
  List<String?> imageList = [];
  String type = Constant.PREVIEW_PHOTO_TYPE_NETWORK;
  int index = 0;
  bool isShowIndex = false;
  bool isDownloadImage = false;
  PageController pageController = PageController();

  @override
  void onReady() {
    super.onReady();
    Map map = Get.arguments as Map;
    imageList = map[Constant.PREVIEW_PHOTO_IMAGE_LIST] ?? [];
    type = map[Constant.PREVIEW_PHOTO_TYPE] ?? Constant.PREVIEW_PHOTO_TYPE_NETWORK;
    index = map[Constant.PREVIEW_PHOTO_INDEX] ?? 0;
    isShowIndex = map[Constant.PREVIEW_PHOTO_IS_SHOW_INDEX] ?? false;
    isDownloadImage = map[Constant.PREVIEW_PHOTO_IS_DOWNLOAD_IMAGE] ?? false;
    pageController = PageController(initialPage: index);
    update();
  }

  void setIndex(int index) {
    this.index = index;
    update();
  }
}
